<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //迭代器
        // var arr = [1,2,3,4,5,]
        // const iterator = arr[Symbol.iterator]()
        // console.log(iterator)
        // let result = iterator.next()
        // console.log(result,"result")
        // while(!result.done){
        //     console.log("当前迭代器循环的值",result.value,"是否迭代完整个集合",result.done)
        //     result = iterator.next()
        // }
        
        //生成器
        function* shengchengqi(){
            let [prev,curr] = [0,1]
            while(true){
                [prev,curr] = [curr,prev+curr]
                yield curr
            }
        }
        var result = shengchengqi()
        console.log(result.next().value)
        console.log(result.next().value)
        console.log(result.next().value)
        console.log(result.next().value)
        console.log(result.next().value)
        console.log(result.next().value)

    </script>
</head>
<body>
    
</body>
</html>
